package top.songxs.gmall.user.biz.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.songxs.gmall.cart.vo.UserAuthInfoVo;
import top.songxs.gmall.common.util.UserAuthUtil;
import top.songxs.gmall.user.biz.UserBizService;
import top.songxs.gmall.user.entity.UserAddress;
import top.songxs.gmall.user.mapper.UserAddressMapper;

import java.util.List;

@Service
public class UserBizServiceImpl implements UserBizService {

    @Autowired
    private UserAddressMapper userAddressMapper ;
    @Override
    public List<UserAddress> getAllUserAddress() {

        UserAuthInfoVo userAuthInfo = UserAuthUtil.getUserAuthInfo();
        String userId = userAuthInfo.getUserId();
        LambdaQueryWrapper<UserAddress> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserAddress::getUserId,Long.parseLong(userId));
        List<UserAddress> userAddresses = userAddressMapper.selectList(wrapper);

        return userAddresses;
    }
}
